.TH deductionguidesforstd::optional 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
deductionguidesforstd::optional \- deductionguidesforstd::optional

.SH Synopsis
   Defined in header <optional>
   template< class T >           \fI(since C++17)\fP
   optional(T) -> optional<T>;

   One deduction guide is provided for std::optional to account for the edge cases
   missed by the implicit deduction guides, in particular, non-copyable arguments and
   array to pointer conversion.

.SH Example


// Run this code

 #include <optional>
 #include <type_traits>

 int main()
 {
     int a[2];
     std::optional oa{a}; // uses explicit deduction guide
     static_assert(std::is_same_v<decltype(oa), std::optional<int*>> == true);
 }
